<template>
  <div>
    <home-header ></home-header>
    <home-swiper :list="list"></home-swiper>
    <home-icons :list="iconList"></home-icons>
    <home-recommend :list="recommendList"></home-recommend>
    <home-weekend :list="weekendList"></home-weekend>
  </div>

</template>
<script>
import HomeHeader from "./components/homeHeader";
import HomeSwiper from "./components/Swiper";
import HomeIcons from "./components/icons";
import HomeRecommend from "./components/recommend";
import HomeWeekend from "./components/weekend";
import axios from "axios";
import {mapState,mapMutations} from 'vuex'
export default {
  name: "home",
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeRecommend,
    HomeWeekend
  },
  data(){
    return{
       lastCity:""
    }
  },
  mounted() {
    this.lastCity=this.city
    this.getHomeInfo()
  
   
  },
  activated(){
     if(this.lastCity!==this.city){
       this.lastCity=this.city
        this.getHomeInfo()
     }
  },
  computed:{
      ...mapState(['city'])
  },
  data() {
    return {
     
      list: [],
      iconList: [],
      recommendList:[],
      weekendList:[]
    };
  },

  methods: {
    getHomeInfo() {
      axios.get("/api/index.json?city="+this.city).then(this.getHomeInfoSucc);
    },
    getHomeInfoSucc(res) {
      res = res.data;
      console.log(res);
      if (res.ret && res.data) {
        const data = res.data;
      
        this.list = data.swiperList;
        this.iconList = data.iconList;
        this.recommendList=data.recommendList
        this.weekendList=data.weekendList
      }
    }
  }
};
</script>
<style>
@font-face {
  font-family: "iconfont"; /* project id 713120 */
  src: url("//at.alicdn.com/t/font_713120_m6zgqgdjge7.eot");
  src: url("//at.alicdn.com/t/font_713120_m6zgqgdjge7.eot?#iefix")
      format("embedded-opentype"),
    url("//at.alicdn.com/t/font_713120_m6zgqgdjge7.woff") format("woff"),
    url("//at.alicdn.com/t/font_713120_m6zgqgdjge7.ttf") format("truetype"),
    url("//at.alicdn.com/t/font_713120_m6zgqgdjge7.svg#iconfont") format("svg");
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
</style>




